<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Agregar.aspx.cs" Inherits="loggedin_Agregar" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link rel="stylesheet" href="../css/wide.css" type="text/css" media="screen, projection" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="NavigationContent" runat="Server">
    <ul id="main-nav" class="clearfix">
        <li><a href="../Default.aspx">Inicio</a></li>
        <li>Mis Libros</li>
        <li><a href="Listar.aspx">Listar</a></li>
        <li id="right-tab"><a href="Contacto.aspx">Contacto</a></li>
    </ul>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="Server">
    <span style="color: #ffffff">Agrega los libros que quieras prestar:</span>
    <br />
    <div style="margin-left: auto; margin-right: auto; text-align: left;">
        <table cellpadding="4px" cellspacing="2px" style="width: 100%; border-top: navy 2px solid;
            margin-top: 15px; border-left-width: thin; border-left-color: silver; border-bottom-width: thin;
            margin-bottom: 2px; border-bottom-color: silver; background-color: lightsteelblue;
            text-align: center; border-right-width: thin; border-right-color: silver">
            <tr>
                <td style="width: 89px" align="left">
                    <asp:Label ID="Label4" runat="server" Text="Titulo:" Font-Bold="True" ForeColor="White"></asp:Label></td>
                <td align="left">
                    <asp:TextBox ID="txtTitulo" runat="server" Width="80%"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 89px" align="left">
                    <asp:Label ID="Label2" runat="server" Text="Autor:" Font-Bold="True" ForeColor="White"></asp:Label></td>
                <td align="left">
                    <asp:TextBox ID="txtAutor" runat="server" Width="80%"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 89px" align="left">
                    <asp:Label ID="Label3" runat="server" Text="Editorial:" Font-Bold="True" ForeColor="White"
                        Width="45px"></asp:Label></td>
                <td align="left">
                    <asp:TextBox ID="txtEditorial" runat="server" Width="80%"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 89px; height: 20px;" align="left">
                    <asp:Label ID="Label6" runat="server" Font-Bold="True" ForeColor="White" Text="URL Foto:"
                        Width="60px"></asp:Label>&nbsp;</td>
                <td style="height: 20px" align="left">
                    <asp:TextBox ID="txtUrlFoto" runat="server" Width="80%"></asp:TextBox></td>
            </tr>
            <tr>
                <td align="left" style="width: 89px; height: 33px">
                </td>
                <td align="left" style="height: 33px">
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 89px">
                </td>
                <td align="right">
                    <asp:Button ID="btnAgregar" runat="server" OnClick="btnAgregar_Click" Text="Agregar" /></td>
            </tr>
        </table>
        <br />
        <br />
        <asp:Label ID="Label5" runat="server" ForeColor="White" Text="Estos son tus libros hasta el momento:"></asp:Label></div>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="90%" PageSize="4"
        OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing"
        OnRowUpdating="GridView1_RowUpdating" OnRowDeleting="GridView1_RowDeleting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged1">
        <Columns>
            <asp:TemplateField HeaderText="Titulo">
                <EditItemTemplate>
                    <asp:TextBox ID="txtTitulo" runat="server" Text='<%# Bind("Titulo") %>' 
                        Width="80px"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblTitulo" runat="server" Text='<%# Bind("Titulo") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Autor">
                <EditItemTemplate>
                    <asp:TextBox ID="txtAutor" runat="server" Text='<%# Bind("Autor") %>' 
                        Width="80px"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Autor") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Editorial">
                <EditItemTemplate>
                    <asp:TextBox ID="txtEditorial" runat="server" Text='<%# Bind("Editorial") %>' 
                        Width="80px"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Editorial") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="ImagenLibro" Visible="False">
                <EditItemTemplate>
                    <asp:TextBox ID="txtUrlFotoInvisible" runat="server" Text='<%# Bind("ImagenLibro") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("ImagenLibro") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Disponible">
                <EditItemTemplate>
                    <asp:DropDownList ID="cmbDisponible" runat="server" 
                        SelectedValue='<%# Eval("Disponible") %>' Width="40px">
                        <asp:ListItem Value="S" Text="Si"></asp:ListItem>
                        <asp:ListItem Value="N" Text="No"></asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lbDisponible" runat="server" Text='<%# Eval("Disponible") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="id" InsertVisible="False" Visible="False">
                <EditItemTemplate>
                    <asp:Label ID="lblId" runat="server" Text='<%# Eval("id") %>' Width="39px"></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblIdForDeletion" runat="server" Text='<%# Bind("id") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Imagen">
                <EditItemTemplate>
                    <asp:TextBox ID="txtUrlFoto" runat="server" Text='<%# Eval("ImagenLibro") %>' Width="121px"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Image  ID="Image1" runat="server" ImageUrl='<%#SetImage(Eval("ImagenLibro"))%>' Height="75px"
                        Width="60px" />
                </ItemTemplate>
                <ItemStyle Height="10px" Width="60px" />
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButtonUpdate" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Grabar"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButtonCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Cancelar"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButtonEdit" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Editar"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False" InsertVisible="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButtonDelete" runat="server" CausesValidation="False" CommandName="Delete"
                        Text="Borrar" OnClientClick="if (!confirm('Estas seguro, borrar el libro?')) return false;"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <RowStyle BackColor="White" />
        <HeaderStyle BackColor="#E0E0E0" ForeColor="Black" />
        <AlternatingRowStyle BackColor="WhiteSmoke" />
    </asp:GridView>
    &nbsp;
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:autoGeneratedConnection %>"
        SelectCommand="SELECT tblLibros.Titulo, tblLibros.Autor, tblEditoriales.Editorial, tblLibros.ImagenLibro, tblLibros.Disponible, tblLibros.id FROM tblLibros INNER JOIN tblEditoriales ON tblLibros.id_Editorial = tblEditoriales.id INNER JOIN aspnet_Users ON tblLibros.UserId = aspnet_Users.UserId"
        OldValuesParameterFormatString="original_{0}"></asp:SqlDataSource>
    &nbsp;<br />
    <br />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Destacados" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="BusquedaAvanzada" runat="Server">
</asp:Content>
